﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Tipler.DataSetler;
using Tipler.Siniflar;
using Tipler.Enumlar;

namespace IKYSWeb
{
    public partial class _Personel : System.Web.UI.MasterPage
    {
        public string sTheme
        {
            get
            {
                if (Context.Request.Cookies["theme"] == null)
                    return VirtualPathUtility.ToAbsolute("~/App_Themes/dib/dibwide.css");
                return VirtualPathUtility.ToAbsolute("~/App_Themes/dib/" + Context.Request.Cookies["theme"].Value + ".css");
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("tr-TR");
            System.Threading.Thread.CurrentThread.CurrentCulture = ci;
            System.Threading.Thread.CurrentThread.CurrentUICulture = ci;

            if (!Page.IsPostBack)
            {
                if (AktifKullanici.KullaniciBilgisi != null)
                {
                    lblKullaniciAdi.Text = AktifKullanici.KullaniciBilgisiRow.Adi + " " + AktifKullanici.KullaniciBilgisiRow.Soyadi + "(" + AktifKullanici.KullaniciBilgisiRow.KullaniciAdi + ")";
                    ltMenu.Text = AktifKullanici.KullaniciMenuStrGetir();

                    //// Merkez Taşra Kontrolü ve Taşra Personeli İçin Birim Gösterme İşlemi Yapılıyor
                    //if (AktifKullanici.KullaniciBilgisiRow.YetkiLITESKILAT == Convert.ToByte(EnumYetkiliTeskilat.Birim_Yetkilisi))
                    //    lblKullaniciAdi.Text += " / " + AktifKullanici.AktifKullaniciBirim;
                }

                
                //if (CachePage.PARAMETRERowGetir(ParametreAdlari.UygulamaUyariMesajiAcik.GetHashCode()) != null &&  Convert.ToBoolean(CachePage.PARAMETRERowGetir(ParametreAdlari.UygulamaUyariMesajiAcik.GetHashCode()).DEGER) == true)
                //{
                //    pnlUyariMesaji.Visible = true;
                //    lblUyariMesaji.Text = CachePage.PARAMETRERowGetir(ParametreAdlari.UygulamaUyariMesaji.GetHashCode()).DEGER;
                //}
                //else
                    pnlUyariMesaji.Visible = false; 

                if (ConfigurationManager.AppSettings["EndpointType"] == "Test")
                    pnlTestMesaji.Visible = true;
                else
                    pnlTestMesaji.Visible = false;
            }
        }



        #region Tema İşlemleri
        protected void darTema_Click(object sender, EventArgs e)
        {
            HttpCookie tema = new HttpCookie("theme", "dib");
            tema.Expires = DateTime.Now.AddYears(1);
            Response.Cookies.Add(tema);
            Response.Redirect(Request.Url.PathAndQuery);
        }

        protected void genisTema_Click(object sender, EventArgs e)
        {
            HttpCookie tema = new HttpCookie("theme", "dibwide");
            tema.Expires = DateTime.Now.AddYears(1);
            Response.Cookies.Add(tema);
            Response.Redirect(Request.Url.PathAndQuery);
        }
        #endregion
        protected void sm_AsyncPostBackError(object sender, AsyncPostBackErrorEventArgs e)
        {
            BasePage.HatayiMailAtveLogla(e.Exception, "AsyncPostBackError ile yakalanan hata");
            //if (e.Exception.Data["ExtraInfo"] != null)
            //{
            //    sm.AsyncPostBackErrorMessage =
            //        e.Exception.Message +
            //        e.Exception.Data["ExtraInfo"].ToString();
            //}
            //else
            //{
            //    sm.AsyncPostBackErrorMessage =
            //        "An unspecified error occurred."; 
            //}
        }
    }
}
